#ifndef NODE_H
#define NODE_H

#include <QVector>
#include <QString>
#include <QGraphicsObject>
#include <QRectF>

#include <QtGui>

class Graph;
class Edge;
class QualAttribute;

class Node : public QGraphicsObject
{
    Q_OBJECT
public:
    Node(QString name, Graph *graph );
    ~Node();
//    Node(const Node& copy);

    void addEdge(Edge* e);
    QList<Edge *> edges() const;

    bool advance();
    void calculateForces();

    QString getName();

    void addAttribute(QPointer<QualAttribute> att);

signals:
    void hoverEnterSignal( );
    void hoverLeaveSignal( );
    void nodeMoved(QPointF newPosition);

public slots:
    void hoverEnterSlot( );
    void hoverLeaveSlot( );
    void moveNode(QPointF newPosition);

protected:
    QRectF boundingRect() const;
    QPainterPath shape() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

    QVariant itemChange(GraphicsItemChange change, const QVariant &value);

    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
    void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);

    void changeAfterHoverEnter();
    void changeAfterHoverLeave();

private:
    Graph *graph;
    QList<Edge *> edgeList;
    QString name;
    QPointF newPos;
    QColor mainColor;
    QColor borderColor;
    QPen outlinePen;
    int nodeWidth;
    QGraphicsObject* parent;

    QVector< QPointer<QualAttribute> > attributes;
};

#endif // NODE_H
